package com.example.MyPritice;

public class DeadLockTestClass {
    private final Object a;
    private final Object b;

    public DeadLockTestClass(Object a, Object b) {
        this.a = a;
        this.b = b;
    }
    public void deadLock(){
        System.out.println("即将死锁");
        synchronized (a) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            synchronized (b){
                System.out.println("全部获取锁");
            }
        }
    }
}
